<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
<%
// *** Logout the current user.
String MM_Logout = request.getRequestURI() + "?MM_Logoutnow=1";
if (request.getParameter("MM_Logoutnow") != null && request.getParameter("MM_Logoutnow").equals("1")) {
  session.putValue("MM_Username", "");
  session.putValue("MM_UserAuthorization", "");
  String MM_logoutRedirectPage = "index.jsp";
  // redirect with URL parameters (remove the "MM_Logoutnow" query param).
  if (MM_logoutRedirectPage.equals("")) MM_logoutRedirectPage = request.getRequestURI();
  if (MM_logoutRedirectPage.indexOf("?") == -1 && request.getQueryString() != null) {
    String MM_newQS = request.getQueryString();
    String URsearch = "MM_Logoutnow=1";
    int URStart = MM_newQS.indexOf(URsearch);
    if (URStart >= 0) {
      MM_newQS = MM_newQS.substring(0,URStart) + MM_newQS.substring(URStart + URsearch.length());
    }
    if (MM_newQS.length() > 0) MM_logoutRedirectPage += "?" + MM_newQS;
  }
  response.sendRedirect(response.encodeRedirectURL(MM_logoutRedirectPage));
  return;
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>POWA Store [Home]</title>
<%
String theUser="";
if(session.getAttribute("MM_Username")!=null&&!session.getAttribute("MM_Username").equals("")){
	theUser=session.getAttribute("MM_Username").toString();
}
%>
</head>

<body>
<table width="80%" align="center">
<tr><td>
<div align="center">
<%if (!theUser.equals("")){out.println("Welcome "+theUser+",");}%>
<h1>This is POWA Web Store </h1>
<h2><a href="Product/" >Browse Our Product</a></h2>
<%if (!theUser.equals("")){
	String MM_authorizedUsers="146240,151945,152786,153948";
	if(MM_authorizedUsers.indexOf((String)session.getValue("MM_UserAuthorization")) >=0){
		out.println("<p><a href=\"Product/manageProduct.jsp\">Manage Store Product</a></p>");
	}
	out.println("<p><a href=\"Account/\">Update Profile</a></p>");
	out.println("<p><a href=\""+MM_Logout+"\">Log out</a></p>");
}else{
	out.println("<p><a href=\"login.jsp\">Login</a></p>");
	out.println("New User? <a href=\"Account/newAccount.jsp\">Sign Up</a>");
}%>
      
      
</div></td></tr>
</table>

</body>
</html>
